// components/Songlist/Songlist.js
Component({
    lifetimes:{
        attached(){
            setTimeout(() => {
                this.getSongs()            
            }, 500);
        }
       
    },
    /**
     * 组件的属性列表
     */
    properties: {
        songlist:Array
    },

    /**
     * 组件的初始数据
     */
    data: {
        // songlist:[]
        songs:[]
    },

    /**
     * 组件的方法列表
     */
    methods: {
         getSongs(){         
            wx.showLoading({
              title: 'loading...',
            })
            setTimeout(async () => {
                let s = ""
                for (let i = 0; i < this.data.songlist.length; i++) {
                    const item = this.data.songlist[i];
                    s += item.id
                    if(i != this.data.songlist.length-1)
                        s += ','
                }
                let res = await wx.p.request({
                    url:`${wx.root}/song/detail`,
                    data:{
                        ids:s
                    }
                })
                this.setData({
                    songs:res.data.songs
                })
                wx.hideLoading({
                  success: (res) => {},
                })
            }, 200);
            
        }
    },
    
})
